import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void setStatusBarStyle(Brightness brightness) {
  SystemChrome.setSystemUIOverlayStyle(
    brightness == Brightness.dark
        ? SystemUiOverlayStyle(
            statusBarColor: Colors.transparent, // 状态栏背景色为透明
            statusBarIconBrightness: Brightness.light, // 状态栏字体为亮色
            statusBarBrightness: Brightness.dark,
          )
        : SystemUiOverlayStyle(
            statusBarColor: Colors.transparent, // 状态栏背景色为透明
            statusBarIconBrightness: Brightness.dark, // 状态栏字体为暗色
            statusBarBrightness: Brightness.light,
          ),
  );
}

ThemeData createThemeData(Brightness brightness, Color primaryColor) {
  setStatusBarStyle(brightness);
  return ThemeData(
    brightness: brightness,
    colorScheme: brightness == Brightness.light
        ? ColorScheme.light(
            surface: Colors.grey.shade200,
            onSurface: Colors.grey.shade900,
            primary: primaryColor,
            primaryContainer: Colors.white,
            secondary: Colors.grey.shade300,
            inversePrimary: Colors.grey.shade800,
            shadow: const Color.fromARGB(112, 80, 80, 80),
          )
        : ColorScheme.dark(
            surface: const Color.fromARGB(255, 39, 39, 42),
            onSurface: Colors.grey.shade100,
            primary: primaryColor,
            primaryContainer: const Color.fromARGB(255, 31, 32, 33),
            secondary: const Color.fromARGB(255, 63, 63, 63),
            inversePrimary: Colors.grey.shade200,
            shadow: const Color.fromARGB(48, 248, 248, 248),
          ),
    fontFamily: Platform.isWindows ? "Microsoft YaHei" : null,
  );
}

ThemeData lightMode = createThemeData(Brightness.light, Colors.blueAccent);
ThemeData darkMode = createThemeData(Brightness.dark, Colors.blueAccent);
